package gitapp.oschina.net.my_osc.common;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

/**
 * @author Tristan-Hou
 * 广播控制器
 */
public class BroadcastController {

    public static final String ACTION_USERCHANGE = "git.oschina.net.ACTION_USERCHANGE";

    public static void sendUserChangeBroadcast(Context context){
        context.sendBroadcast(new Intent(ACTION_USERCHANGE));
    }

    public static void registerUserChangeReceiver(
            BroadcastReceiver broadcastReceiver, Context context){
        IntentFilter intentFilter = new IntentFilter(ACTION_USERCHANGE);
        context.registerReceiver(broadcastReceiver, intentFilter);
    }

    public static void unregisterReceiver(
            Context context, BroadcastReceiver broadcastReceiver){
        context.unregisterReceiver(broadcastReceiver);
    }
}
